package com.junyu.exception;

import com.junyu.common.ResultCodeEnum;
import lombok.Data;

/**
 * 自定义异常类
 */
@Data
public class LoginException extends RuntimeException {
    private Integer code;
    private String message;
    private Throwable e;

    /**
     * 构造方法
     * @param code    状态码
     * @param message 错误信息
     */
    public LoginException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 构造方法
     * @param code
     * @param message
     * @param e
     */
    public LoginException(Integer code, String message, Throwable e) {
        this.code = code;
        this.message = message;
        this.e = e;
    }

    /**
     * 构造方法
     * @param resultCodeEnum 响应状态码
     * @param e 异常对象
     */
    public LoginException(ResultCodeEnum resultCodeEnum, Throwable e) {
        this(resultCodeEnum.getCode(), resultCodeEnum.getMessage(), e);
    }

    /**
     * 构造方法
     * @param resultCodeEnum 响应状态码
     */
    public LoginException(ResultCodeEnum resultCodeEnum) {
        this(resultCodeEnum.getCode(), resultCodeEnum.getMessage());
    }
}